<?php
function displayAdminMembers($projectID,$maxUsers)
{
	global $database,$session;
	$result = $database->query("SELECT * FROM ".TBL_PROJECT_MEMBERS." WHERE projectID='$projectID'");
	$num_rows = mysql_num_rows($result);
	
	if($num_rows<=0)
	{
		echo "<center>No Members Available</center>";
	}
	else
	{
		
		$start = 0;
		if(isset($_GET['start']))
		{
			$start = $_GET['start'];
		}
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr>";
		echo "<td><center><b>Username</b></center></td>";
		echo "<td><center><b>User Level</b></center></td>";
		echo "<td><center><b>Date Joined</b></center></td>";
		echo "<td><center><b>Delete</b></center></td>";
		echo "</tr>";
		for($i=$start;$i<$num_rows && $i<$start+$maxUsers;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$user = mysql_result($result,$i,"username");
			$userlevel = mysql_result($result,$i,"userlevel");
			$time = mysql_result($result,$i,"timestamp");
			echo "<tr>";
			echo "<td><center><a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></center></td>";
			echo "<td>";
			echo "<center><form action=\"includes/process.php\" method=\"POST\">";
			echo "<select name=\"level\" style=\"background-color: #bcc6e1;\">";
			for($x=0;$x<10;$x++)
			{
				echo "<option value=\"$x\" ";
				if($x==$userlevel)
				{
					echo "selected=\"selected\" ";
				}
				echo ">$x</option>";
			}
			echo "</select>";
			echo "<input type=\"hidden\" name=\"subEditMemberlevel\" value=\"$user\" />";
			echo "<input type=\"hidden\" name=\"projectID\" value=\"$projectID\" />";
			echo "<input type=\"submit\" value=\"Promote\" />";
			echo "</form></center>";
			echo "</td>";
			echo "<td><center>".date("M. j, Y",$time)."</center></td>";
			echo "<td><center><a href=\"#\" onClick=\"if(disp_confirm_delete_member()){buttonClick('includes/process.php?deleteMember=$user&projectID=$projectID');}\" class=\"button\" title=\"Delete Member\">Delete</a></center></td>";
			echo "</tr>";
		}
		echo "</table>";
		echo "<br /><center>";
		for($x=0;$x<$num_rows;$x=$x+$maxUsers)
		{
			if($start!=$x)
				echo "<a href=\"editProjectMembers.php?start=$x\">".(($x/$maxUsers)+1)."</a>&nbsp;&nbsp;&nbsp;";
			else
				echo (($x/$maxUsers)+1)."&nbsp;&nbsp;&nbsp;";
		}
		echo "</center>";
	}
}
function displayLatestProjectNews($maxNews)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_PROJECT_NEWS." ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);
	
	if($num_rows<=0)
	{
		echo "<center>No News Posted</center>";
	}
	else
	{
		for($i=0; $i<$num_rows && $i<$maxNews; $i++)
		{
			$id = mysql_result($result,$i,"id");
			$projectID = mysql_result($result,$i,"projectID");
			$title = mysql_result($result,$i,"title");
			$content = mysql_result($result,$i,"content");
			$time = mysql_result($result,$i,"timestamp");
			$user = mysql_result($result,$i,"author");
			
			$retval = $database->query("SELECT name FROM ".TBL_PROJECTS." WHERE id='$projectID'");
			$arrayProject = mysql_fetch_array($retval);
			
			echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
			echo "<tr><td><font size=\"+1\"><b>$title</b></font> - <a href=\"viewProject.php?id=$projectID\" title=\"Visit Project Page\"><b>".$arrayProject['name']."</b></a></td></tr>";
// //linha maradal: 			echo "<tr><td><font color=\"#2f3c62\"><b>".date("F j, Y")." - by <a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></b></font><br /><br /></td></tr>";
			echo "<tr><td><font color=\"#2f3c62\"><b>".date("F j, Y - g:i A",$time)." - by <a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></b></font><br /><br /></td></tr>";
			
			echo "<tr><td>$content</td></tr>";
			echo "</table><br />";
		}
	}
}
function displayProjectNews($projectID,$maxNews)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_PROJECT_NEWS." WHERE projectID='$projectID' ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);
	
	if($num_rows<=0)
	{
		echo "<center>No News Posted</center>";
	}
	else
	{
		$start = 0;
		if(isset($_GET['start']))
		{
			$start = $_GET['start'];
		}
		for($i=$start;$i<$num_rows && $i<$start+$maxNews;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$title = mysql_result($result,$i,"title");
			$content = mysql_result($result,$i,"content");
			$time = mysql_result($result,$i,"timestamp");
			$user = mysql_result($result,$i,"author");
			echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
			echo "<tr><td><font size=\"+1\"><b>$title</b></font></td></tr>";
			echo "<tr><td><font color=\"#2f3c62\"><b>".date("F j, Y - g:i A",$time)." - by <a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></b></font><br /><br /></td></tr>";
			echo "<tr><td>$content<br /><br /></td></tr>";
			echo "</table><br />";
		}
		echo "<br /><center>";
		for($x=0;$x<$num_rows;$x=$x+$maxNews)
		{
			if($start!=$x)
				echo "<a href=\"viewProject.php?id=".$_GET['id']."&start=$x\">".(($x/$maxNews)+1)."</a>&nbsp;&nbsp;&nbsp;";
			else
				echo (($x/$maxNews)+1)."&nbsp;&nbsp;&nbsp;";
		}
		echo "</center>";
	}
}
function displayProjectNewsAdmin($projectID,$maxNews)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_PROJECT_NEWS." WHERE projectID='$projectID' ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center>No News Posted</center>";
	}
	else
	{
		$start = 0;
		if(isset($_GET['start']))
		{
			$start = $_GET['start'];
		}
		for($i=$start;$i<$num_rows && $i<$start+$maxNews;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$title = mysql_result($result,$i,"title");
			$content = mysql_result($result,$i,"content");
			$time = mysql_result($result,$i,"timestamp");
			$user = mysql_result($result,$i,"author");
			echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
			echo "<tr><td><font size=\"+1\"><b>$title</b></font></td></tr>";
			echo "<tr><td><font color=\"#2f3c62\"><b>".date("F j, Y - g:i A",$time)." - by <a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></b></font><br /><br /></td></tr>";
			echo "<tr><td>$content<br /><br /></td></tr>";
			echo "<tr><td align=\"right\"><a href=\"editProjectNews.php?id=$projectID&edit=$id\" title=\"Edit News\">Edit</a>&nbsp;&nbsp;&nbsp;&nbsp;";
			echo "<a href=\"includes/process.php?deleteProjectNews=$projectID&news=$id\" title=\"Delete News\">Delete</a><br /></td></tr>";
			echo "</table>";
		}
		echo "<br /><center>";
		for($x=0;$x<$num_rows;$x=$x+$maxNews)
		{
			if($start!=$x)
				echo "<a href=\"editProjectNews.php?id=$projectID&start=$x\">".(($x/$maxNews)+1)."</a>&nbsp;&nbsp;&nbsp;";
			else
				echo (($x/$maxNews)+1)."&nbsp;&nbsp;&nbsp;";
		}
		echo "</center>";
	}
}
function displayAdminLinks()
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_LINKS." ORDER BY likes DESC, timestamp ASC");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center>No Links Added</center>";
	}
	else
	{
		
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><center><b>Link</b></center></td><td><center><b>Description</b></center></td><td><center><b>Edit</b></center></td><td><center><b>Delete</b></center></td></tr>";
		for($i=0;$i<$num_rows;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$link = mysql_result($result,$i,"link");
			$url = mysql_result($result,$i,"url");
			$description = mysql_result($result,$i,"description");
			$likes = mysql_result($result,$i,"likes");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center><a href=\"includes/process.php?addLike=$id&type=1\" title=\"Like This Link?\" target=\"_blank\">Likes $likes</a></center></td>";
			echo "<td><center><a href=\"$url\" title=\"Visit Site\" target=\"_blank\">$link</a></center></td>";
			echo "<td><center>$description</center></td>";
			echo "<td><center><input type=\"button\" onClick=\"window.location='adminLinks.php?edit=$id'\" value=\"Edit\" /></center></td>";
			echo "<td><center><input type=\"button\" onClick=\"if(disp_confirm_delete_link()){window.location='includes/process.php?deleteLink=$id'}\" value=\"Delete\" /></center></td>";
			echo "</tr>";
		}
		echo "</table>";
	}
}
function displayUserLinks($user)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_LINKS." WHERE creator='$user' ORDER BY timestamp ASC");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center>No Links Added</center>";
	}
	else
	{
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		for($i=0;$i<$num_rows;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$link = mysql_result($result,$i,"link");
			$url = mysql_result($result,$i,"url");
			$description = mysql_result($result,$i,"description");
			$user = mysql_result($result,$i,"creator");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#d0d0d0\"";
			}
			echo ">";
			echo "<td><center><a href=\"$url\" title=\"Visit Site\" target=\"_blank\">$link</a></center></td>";
			echo "<td><center>$description</center></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td></td>";
			echo "<td></td>";
			echo "</tr>";
		}
		echo "</table>";
	}
}
function displayAllLinks()
{
	global $session, $database;
	$result = $database->query("SELECT * FROM ".TBL_LINKS." ORDER BY likes DESC, timestamp ASC");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center><h3>No Links Added</h3></center>";
	}
	else
	{
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		for($i=0;$i<$num_rows;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$link = mysql_result($result,$i,"link");
			$url = mysql_result($result,$i,"url");
			$description = mysql_result($result,$i,"description");
			$user = mysql_result($result,$i,"creator");
			$likes = mysql_result($result,$i,"likes");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#d0d0d0\"";
			}
			echo ">";
			echo "<td><center>";
			if($session->logged_in)
			{
				echo "<a href=\"includes/process.php?addLike=$id&type=1\" title=\"Like this Link?\">Likes $likes</a>";
			}
			else
			{
				echo "Likes $likes";
			}
			echo "</center></td>";
			echo "<td><center><a href=\"$url\" title=\"Visit Site\" target=\"_blank\">$link</a></center></td>";
			echo "<td><center>$description</center></td>";
			echo "<td><center><a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></center></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td></td>";
			echo "<td></td>";
			echo "<td></td>";
			echo "<td></td>";
			echo "</tr>";
		}
		echo "</table>";
	}
}
function displayOwnerLinks($user)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_LINKS." WHERE creator='$user'");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center><h3>No Links Added</h3></center>";
	}
	else
	{
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><center><b>Link</b></center></td><td><center><b>Description</b></center></td><td><center><b>Edit</b></center></td><td><center><b>Delete</b></center></td></tr>";
		for($i=0;$i<$num_rows;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$link = mysql_result($result,$i,"link");
			$url = mysql_result($result,$i,"url");
			$description = mysql_result($result,$i,"description");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center><a href=\"$url\" title=\"Visit Site\" target=\"_blank\">$link</a></center></td>";
			echo "<td><center>$description</center></td>";
			echo "<td><center><input type=\"button\" onClick=\"window.location='editLinks.php?edit=$id'\" value=\"Edit\" /></center></td>";
			echo "<td><center><input type=\"button\" onClick=\"if(disp_confirm_delete_link()){window.location='includes/process.php?deleteLink=$id'}\" value=\"Delete\" /></center></td>";
			echo "</tr>";
		}
		echo "</table>";
	}
}
function displayProjectMembers($id)
{
	global $database;
	
	$q = "SELECT * FROM ".TBL_PROJECT_MEMBERS." WHERE projectID='$id' AND userlevel>=1 ORDER BY timestamp ASC";
	$result = $database->query($q);
	
	//no feedback
	$num_rows = mysql_num_rows($result);
	if(!$result || ($num_rows < 0))
	{
		echo "<center>Error Displaying Info</center>";
		return;
	}
	if($num_rows == 0)
	{
		echo "<center>No Members Available</center>";
		return;
	}
	
	echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
	echo "<tr><td><center><b>Members ($num_rows)</b></center></td></tr>";
	for($i=0; $i<$num_rows; $i++)
	{
		$name = mysql_result($result,$i,"username");
		
		echo "<tr><td>";
		echo "<center><a href=\"profile.php?user=$name\" title=\"View Profile\">$name</a></center>";
		echo "</td></tr>";
	}
	echo "</table>";
}
function displayAdminFeedback()
{
	global $database;
	
	$q = "SELECT * FROM ".TBL_FEEDBACK." ORDER BY timestamp DESC";
	$result = $database->query($q);
	
	//no feedback
	$num_rows = mysql_num_rows($result);
	if(!$result || ($num_rows < 0))
	{
		echo "<center><h3>Error Displaying Info</h3></center>";
		return;
	}
	if($num_rows == 0)
	{
		echo "<center><h3>No Feedback Available</h3></center>";
		return;
	}
	
	// Display table contents
	echo "<center>";
	echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\">";
	for($i=0; $i<$num_rows; $i++)
	{
		$id = mysql_result($result,$i,"id");
		$name = mysql_result($result,$i,"username");
		$email = mysql_result($result,$i,"email");
		$subject = mysql_result($result,$i,"subject");
		$feedback = mysql_result($result,$i,"feedback");
		$timestamp = mysql_result($result,$i,"timestamp");
		$reviewed = mysql_result($result,$i,"reviewed");
		
		echo "<tr><td>";
		echo "<b>$subject</b><br /><br />";
		echo "$feedback<br /><br />";
		echo "By ";
		if($email=="")
		{
			echo "<a href=\"profile.php?user=$name\" title=\"View Profile\">$name</a>";
		}
		else
		{
			echo $name;
		}
		echo ", ".date("M. j, Y - g:i a",$timestamp)."<br />";
		echo "$email<br /><br />";
		if($reviewed==0)
		{
			echo "<input type=\"button\" onclick=\"window.location='includes/process.php?reviewedFeedback=$id'\" value=\"Reviewed\" />";
		}
		echo "<input type=\"button\" onclick=\"window.location='includes/process.php?deleteFeedback=$id'\" value=\"Delete\" />";
		echo "<center><hr width=\"90%\" /></center><br />";
		echo "</td></tr>";
	}
	echo "</table>";
	echo "</center>";
}
function displayUsersByCountry($country)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_USERS." WHERE country='$country'");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center>No Users Where Found</center>";
	}
	else
	{
		$maxUsers = 10;
		$start = 0;
		if(isset($_GET['start']))
		{
			$start = $_GET['start'];
		}
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr>";
		echo "<td><center><b>Image</b></center></td>";
		echo "<td><center><b>Username</b></center></td>";
		echo "<td><center><b>My Thoughts on the Movement</b></center></td>";
		echo "<td><center><b>City</b></center></td>";
		echo "<td><center><b>State</b></center></td>";
		echo "</tr>";
		for($i=$start;$i<$num_rows && $i<$start+$maxUsers;$i++)
		{
			$pic = mysql_result($result,$i,"profilePic");
			$user = mysql_result($result,$i,"username");
			$thoughts = mysql_result($result,$i,"thoughts");
			$city = mysql_result($result,$i,"city");
			$state = mysql_result($result,$i,"state");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center><a href=\"profile.php?user=$user\"><img src=\"";
			if($pic=='')
			{
				echo DEFAULT_PROFILE_PIC;
			}
			else
			{
				echo $pic;
			}
			echo "\" width=\"70\" height=\"70\" border=\"1\" /></a></center></td>";
			echo "<td><center><a href=\"profile.php?user=$user\">$user</a></center></td>";
			echo "<td><center>$thoughts</center></td>";
			echo "<td><center>$city</center></td>";
			echo "<td><center>$state</center></td>";
			echo "</tr>";
		}
		echo "</table>";
		echo "<br /><center>";
		for($x=0;$x<$num_rows;$x=$x+$maxUsers)
		{
			if($start!=$x)
				echo "<a href=\"users.php?country=".$country."&start=$x\">".(($x/$maxUsers)+1)."</a>&nbsp;&nbsp;&nbsp;";
			else
				echo (($x/$maxUsers)+1)."&nbsp;&nbsp;&nbsp;";
		}
		echo "</center>";
	}
}
function displayProjectOwnerResources($projectID)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_NEEDS." WHERE projectid='$projectID'");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center>No Resources Currently Needed</center>";
	}
	else
	{
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><center><b>Type</b></center></td><td><center><b>Category</b></center></td><td><center><b>Title</b></center></td><td><center><b>Description</b></center></td><td><center><b>Edit</b></center></td><td><center><b>Delete</b></center></td></tr>";
		for($i=0;$i<$num_rows;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$type = mysql_result($result,$i,"type");
			$category = mysql_result($result,$i,"category");
			$name = mysql_result($result,$i,"title");
			$description = mysql_result($result,$i,"description");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center>$type</center></td><td><center>$category</center></td><td><center>$name</center></td><td><center>$description</center></td>";
			echo "<td><center><a href=\"editProjectResources.php?id=$projectID&edit=$id\">Edit</a></center></td>";
			echo "<td><center><a href=\"#\" onClick=\"if(disp_confirm_delete_needed_resource()){buttonClick('includes/process.php?id=$projectID&deleteNeededResource=$id');}\" class=\"button\" title=\"Delete Needed Resource\">Delete</a></center></td>";
			echo "</tr>";
		}
		echo "</table>";
	}
}
function displayProjectResources($projectID)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_NEEDS." WHERE projectid='$projectID'");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center>No Resources Currently Needed</center>";
	}
	else
	{
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><center><b>Type</b></center></td><td><center><b>Category</b></center></td><td><center><b>Title</b></center></td><td><center><b>Description</b></center></td></tr>";
		for($i=0;$i<$num_rows;$i++)
		{
			$type = mysql_result($result,$i,"type");
			$category = mysql_result($result,$i,"category");
			$name = mysql_result($result,$i,"title");
			$description = mysql_result($result,$i,"description");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center>$type</center></td><td><center>$category</center></td><td><center>$name</center></td><td><center>$description</center></td>";
			echo "</tr>";
		}
		echo "</table>";
	}
}
function displayOwnerProjects($creator)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_PROJECTS." WHERE creator='$creator' ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);

	echo "<center><h2>My Projects</h2></center>";
	if($num_rows<=0)
	{
		echo "<center>No projects currently available.</center>";
	}
	else
	{
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><center><b>Logo</b></center></td>";
		echo "<td><center><b>Name</b></center></td>";
		echo "<td><center><b>Description</b></center></td>";
		echo "<td><center><b>Delete</b></center></td>";
		echo "</tr>";
		for($i=0;$i<$num_rows;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$logo = mysql_result($result,$i,"logoPic");
			if($logo=='')
			{
				$logo = DEFAULT_PROJECT_PIC;
			}
			$name = mysql_result($result,$i,"name");
			$description = mysql_result($result,$i,"description");
			$user = mysql_result($result,$i,"creator");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center><a href=\"viewProject.php?id=$id\" title=\"View Project\"><img src=\"$logo\" width=\"75\" border=\"1\" /></a></center></td>";
			echo "<td><center><a href=\"viewProject.php?id=$id\" title=\"View Project\">$name</a></center></td>";
			echo "<td><center>$description</center></td>";
			echo "<td><center><a href=\"includes/process.php?deleteProject=$id\" title=\"Delete Project\">Delete</a></center></td>";
			echo "</tr>";
		}
		echo "</table>";
	}
}
function displayMemberProjects($user)
{
	global $database;
	$result = $database->query("SELECT projectID FROM ".TBL_PROJECT_MEMBERS." WHERE username='$user' ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);

	echo "<center>";
	echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
	echo "<tr>";
	echo "<td class=\"topLeft\"></td><td bgcolor=\"#dadada\"></td><td class=\"topRight\"></td>";
	echo "</tr>";
	echo "<tr bgcolor=\"#dadada\">";
	echo "<td></td><td>";
		echo "<center><h2>Joined Projects</h2></center>";
		if(isset($_SESSION['leaveProjectSuccess']))
		{
			if($_SESSION['leaveProjectSuccess'])
			{
				echo "<center>Successfully Left Project</center>";
			}
			else
			{
				echo "<center>Leave Project Failed</center>";
			}
			unset($_SESSION['leaveProjectSuccess']);
		}
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr>";
		echo "<td><center><b>Logo</b></center></td>";
		echo "<td><center><b>Name</b></center></td>";
		echo "<td><center><b>Description</b></center></td>";
		echo "<td><center><b>Delete</b></center></td>";
		echo "</tr>";
		for($i=0;$i<$num_rows;$i++)
		{
			$projectID = mysql_result($result,$i,"projectID");
			$retval = $database->query("SELECT * FROM ".TBL_PROJECTS." WHERE id='$projectID' AND creator!='$user'");
			if(mysql_num_rows($retval)!=0)
			{
				$project = mysql_fetch_array($retval);
				if($project['logoPic']=='')
				{
					$project['logoPic'] = DEFAULT_PROJECT_PIC;
				}
				echo "<tr";
				if($i%2==0)
				{
					echo " bgcolor=\"#c9c9c9\"";
				}
				echo ">";
				echo "<td><center><a href=\"viewProject.php?id=".$project['id']."\" title=\"View Project\"><img src=\"".$project['logoPic']."\" width=\"75\" border=\"1\" /></a></center></td>";
				echo "<td><center><a href=\"viewProject.php?id=".$project['id']."\" title=\"View Project\">".$project['name']."</a></center></td>";
				echo "<td><center>".$project['description']."</center></td>";
				echo "<td><center><a href=\"includes/process.php?leaveProject=".$project['id']."&user=$user\" title=\"Leave Project\">Leave</a></center></td>";
				echo "</tr>";
			}
		}
		echo "</table>";
	echo "</td><td></td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"bottomLeft\"></td><td bgcolor=\"#dadada\"></td><td class=\"bottomRight\"></td>";
	echo "</tr>";
	echo "</table>";
	echo "</center>";
	echo "<br />";
}
function displayUserProjects($creator)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_PROJECTS." WHERE creator='$creator' ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center>No projects currently available.</center>";
	}
	else
	{
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><center><b>Logo</b></center></td>";
		echo "<td><center><b>Name</b></center></td>";
		echo "<td><center><b>Description</b></center></td>";
		echo "</tr>";
		for($i=0;$i<$num_rows;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$logo = mysql_result($result,$i,"logoPic");
			if($logo=='')
			{
				$logo = DEFAULT_PROJECT_PIC;
			}
			$name = mysql_result($result,$i,"name");
			$description = mysql_result($result,$i,"description");
			$user = mysql_result($result,$i,"creator");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center><a href=\"viewProject.php?id=$id\" title=\"View Project\"><img src=\"$logo\" width=\"75\" border=\"1\" /></a></center></td>";
			echo "<td><center><a href=\"viewProject.php?id=$id\" title=\"View Project\">$name</a></center></td>";
			echo "<td><center>$description</center></td>";
			echo "</tr>";
		}
		echo "</table>";
	}
}
function displayAllProjects()
{
	global $session, $database;
	$result = $database->query("SELECT * FROM ".TBL_PROJECTS." ORDER BY likes DESC, timestamp DESC");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center>No projects currently available.</center>";
	}
	else
	{
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><center><b>Likes</b></center></td>";
		echo "<td><center><b>Logo</b></center></td>";
		echo "<td><center><b>Name</b></center></td>";
		echo "<td><center><b>Description</b></center></td>";
		echo "<td><center><b>Owner</b></center></td>";
		echo "</tr>";
		for($i=0;$i<$num_rows;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$logo = mysql_result($result,$i,"logoPic");
			if($logo=='')
			{
				$logo = DEFAULT_PROJECT_PIC;
			}
			$name = mysql_result($result,$i,"name");
			$description = mysql_result($result,$i,"description");
			$user = mysql_result($result,$i,"creator");
			$likes = mysql_result($result,$i,"likes");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center>";
			if($session->logged_in)
			{
				echo "<a href=\"includes/process.php?addLike=$id&type=0\" title=\"Like This Project?\">Likes $likes</a>";
			}
			else
			{
				echo "Likes $likes";
			}
			echo "</center></td>";
			echo "<td><center><a href=\"viewProject.php?id=$id\" title=\"View Project\"><img src=\"$logo\" width=\"75\" border=\"1\" /></a></center></td>";
			echo "<td><left><a href=\"viewProject.php?id=$id\" title=\"View Project\">$name</a></left></td>";
			echo "<td><left>$description</left></td>";
			echo "<td><center><a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></center></td>";
			echo "</tr>";
		}
		echo "</table>";
	}
}
function displayCategories()
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_CATEGORIES." ORDER BY type ASC, category ASC");
	$num_rows = mysql_num_rows($result);
	$last = "";

	echo "<ul>";
	for($i=0;$i<$num_rows;$i++)
	{
		$id = mysql_result($result,$i,"id");
		$type = mysql_result($result,$i,"type");
		$category = mysql_result($result,$i,"category");
		$date = mysql_result($result,$i,"timestamp");
		$user = mysql_result($result,$i,"creator");
		if($last != $type)
		{
			echo "</ul><b>$type</b><ul>";
		}
		$last = $type;
		echo "<li>$category - ".date("M. j, Y - g:i a",$date)." - by <a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a> - ";
		echo "<a href=\"#\" onClick=\"if(disp_confirm_delete_category()){buttonClick('includes/process.php?deleteCategory=$id');}\" class=\"button\" title=\"Delete Category\">Delete</a>";
		echo "</li>";
	}
	echo "</ul>";

}
function displayMessages($to)
{
	global $database,$session;
	$result = $database->query("SELECT * FROM ".TBL_MESSAGES." WHERE toUser='$to' ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);

	echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
	echo "<tr><td><center><b>Read</b></center></td>";
	echo "<td><center><b>From</b></center></td>";
	echo "<td><center><b>Subject</b></center></td>";
	echo "<td><center><b>Date</b></center></td>";
	echo "<td><center><b>Delete</b></center></td>";
	echo "</tr>";
	if($num_rows>0)
	{
		for($i=0;$i<$num_rows;$i++)
		{
			$id = mysql_result($result,$i,"id");
			$read = mysql_result($result,$i,"viewed");
			$from = mysql_result($result,$i,"fromUser");
			$subject = mysql_result($result,$i,"subject");
			$date = mysql_result($result,$i,"timestamp");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center><font size=\"-2\">";
			if($read=='0')
				echo "<font color=\"#ff0000\">Unread</font>";
			else
				echo "Read";
			echo "</font></center></td>";
			echo "<td><center><a href=\"profile.php?user=$from\" title=\"View Profile\">$from</a></center></td>";
			echo "<td><center><a href=\"messages.php?read=$id\" title=\"View Message\">$subject</a></center></td>";
			echo "<td><center>".date("D. - M. j, Y - g:i a",$date)."</center></td>";
			echo "<td><center><a href=\"#\" onClick=\"if(disp_confirm_delete_message()){buttonClick('includes/process.php?deleteMessage=$id');}\" class=\"button\" title=\"Delete Message\">Delete</a></center></td>";
			echo "</tr>";
		}
	}
	echo "</table>";
	if($num_rows<=0)
	{
		echo "<br /><br /><center>No Messages Received</center><br />";
	}
}
function displayAdminAllResources()
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_RESOURCES." ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center>No Resources Currently Available</center>";
	}
	else
	{
		$start = 0;
		$maxResources = 30;
		if(isset($_GET['start']))
		{
			$start = $_GET['start'];
		}

		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><center><b>Type</b></center></td>";
		echo "<td><center><b>Category</b></center></td>";
		echo "<td><center><b>Title</b></center></td>";
		echo "<td><center><b>Description</b></center></td>";
		echo "<td><center><b>Country</b></center></td>";
		echo "<td><center><b>Username</b></center></td>";
		echo "</tr>";
		for($i=$start;$i<$num_rows && $i<$start+$maxResources;$i++)
		{
			$type = mysql_result($result,$i,"type");
			$category = mysql_result($result,$i,"category");
			$name = mysql_result($result,$i,"title");
			$description = mysql_result($result,$i,"description");
			$country = mysql_result($result,$i,"country");
			$user = mysql_result($result,$i,"username");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center>$type</center></td>";
			echo "<td><center>$category</center></td>";
			echo "<td><center>$name</center></td>";
			echo "<td><center>$description</center></td>";
			echo "<td><center>$country</center></td>";
			echo "<td><center><a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></center></td>";
			echo "</tr>";
		}
		echo "</table>";
		echo "<center><br />";
		for($x=0;$x<$num_rows;$x=$x+$maxResources)
		{
			if($start!=$x)
				echo "<a href=\"resources.php?start=$x\">".(($x/$maxResources)+1)."</a>&nbsp;&nbsp;&nbsp;";
			else
				echo (($x/$maxResources)+1)."&nbsp;&nbsp;&nbsp;";
		}
		echo "</center>";
	}
}
function displayAllResources($result)
{
	//already initiated database lookup in resources.php
	$num_rows = mysql_num_rows($result);
	
	if($num_rows<=0)
	{
		echo "<center>No Resources Currently Available</center>";
	}
	else
	{
		$start = 0;
		$maxResources = 30;
		if(isset($_GET['start']))
		{
			$start = $_GET['start'];
		}
		
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><center><b>Type</b></center></td>";
		echo "<td><center><b>Category</b></center></td>";
		echo "<td><center><b>Title</b></center></td>";
		echo "<td><center><b>Description</b></center></td>";
		echo "<td><center><b>Country</b></center></td>";
		echo "<td><center><b>Username</b></center></td>";
		echo "</tr>";
		for($i=$start;$i<$num_rows && $i<$start+$maxResources;$i++)
		{
			$type = mysql_result($result,$i,"type");
			$category = mysql_result($result,$i,"category");
			$name = mysql_result($result,$i,"title");
			$description = mysql_result($result,$i,"description");
			$country = mysql_result($result,$i,"country");
			$user = mysql_result($result,$i,"username");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center>$type</center></td>";
			echo "<td><center>$category</center></td>";
			echo "<td><center>$name</center></td>";
			echo "<td><center>$description</center></td>";
			echo "<td><center>$country</center></td>";
			echo "<td><center><a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></center></td>";
			echo "</tr>";
		}
		echo "</table>";
		echo "<center><br />";
		for($x=0;$x<$num_rows;$x=$x+$maxResources)
		{
			if($start!=$x)
				echo "<a href=\"resources.php?start=$x\">".(($x/$maxResources)+1)."</a>&nbsp;&nbsp;&nbsp;";
			else
				echo (($x/$maxResources)+1)."&nbsp;&nbsp;&nbsp;";
		}
		echo "</center>";
	}
}
function displayUserResources($user)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_RESOURCES." WHERE username='$user'");
	$num_rows = mysql_num_rows($result);

	if($num_rows<=0)
	{
		echo "<center>No Resources Currently Available</center>";
	}
	else
	{
		echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><center><b>Type</b></center></td><td><center><b>Category</b></center></td><td><center><b>Title</b></center></td><td><center><b>Description</b></center></td></tr>";
		for($i=0;$i<$num_rows;$i++)
		{
			$type = mysql_result($result,$i,"type");
			$category = mysql_result($result,$i,"category");
			$name = mysql_result($result,$i,"title");
			$description = mysql_result($result,$i,"description");
			echo "<tr";
			if($i%2==0)
			{
				echo " bgcolor=\"#c9c9c9\"";
			}
			echo ">";
			echo "<td><center>$type</center></td><td><center>$category</center></td><td><center>$name</center></td><td><center>$description</center></td>";
			echo "</tr>";
		}
		echo "</table>";
	}
}
function displayOwnerResources($user)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_RESOURCES." WHERE username='$user'");
	$num_rows = mysql_num_rows($result);
	echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">";
	echo "<tr><td><center><b>Type</b></center></td><td><center><b>Category</b></center></td><td><center><b>Title</b></center></td><td><center><b>Description</b></center></td><td><center><b>Edit</b></center></td><td><center><b>Delete</b></center></td></tr>";
	for($i=0;$i<$num_rows;$i++)
	{
		$id = mysql_result($result,$i,"id");
		$type = mysql_result($result,$i,"type");
		$category = mysql_result($result,$i,"category");
		$name = mysql_result($result,$i,"title");
		$description = mysql_result($result,$i,"description");
		echo "<tr";
		if($i%2==0)
		{
			echo " bgcolor=\"#c9c9c9\"";
		}
		echo ">";
		echo "<td><center>$type</center></td><td><center>$category</center></td><td><center>$name</center></td><td><center>$description</center></td>";
		echo "<td><center><a href=\"editResources.php?edit=$id\">Edit</a></center></td>";
		echo "<td><center><a href=\"#\" onClick=\"if(disp_confirm_delete_resource()){buttonClick('includes/process.php?deleteResource=$id');}\" class=\"button\" title=\"Delete Resource\">Delete</a></center></td>";
		echo "</tr>";
	}
	echo "</table>";
}
function displayActiveUsers()
{
	global $database;
	$result = $database->query("SELECT username FROM ".TBL_ACTIVE_USERS);
	$num_rows = mysql_num_rows($result);
	if($num_rows==0)
	{
		echo "No Users Online";
	}
	else
	{
		echo "<table cellpadding=\"0\" cellspacing=\"0\">";
		for($i=0;$i<$num_rows;$i++)
		{
			$user = mysql_result($result,$i,"username");
			echo "<tr><td><center><a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></center></td></tr>";
		}
		echo "</table>";
	}
}
function displayActiveUsersNoHTML()
{
	global $database;
	$result = $database->query("SELECT username FROM ".TBL_ACTIVE_USERS);
	$num_rows = mysql_num_rows($result);
	for($i=0;$i<$num_rows;$i++)
	{
		$user = mysql_result($result,$i,"username");
		echo "$user\n";
	}
}
function displayAdminUsers($maxUsers)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_USERS);
	$num_rows = mysql_num_rows($result);
	if($num_rows==0)
	{
		echo "No Users Registered";
	}
	else
	{
		$start = 0;
		if(isset($_GET['start']))
		{
			$start = $_GET['start'];
		}
		echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr>";
		echo "<td><center><b>Username</b></center></td>";
		echo "<td><center><b>User Level</b></center></td>";
		echo "<td><center><b>Last Login</b></center></td>";
		echo "<td><center><b>Country</b></center></td>";
		echo "<td><center><b>Date Registered</b></center></td>";
		echo "<td><center><b>Delete</b></center></td>";
		echo "</tr>";
		for($i=$start;$i<$num_rows && $i<$start+$maxUsers;$i++)
		{
			$userid = mysql_result($result,$i,"userid");
			$user = mysql_result($result,$i,"username");
			$userlevel = mysql_result($result,$i,"userlevel");
			$time = mysql_result($result,$i,"timestamp");
			$country = mysql_result($result,$i,"country");
			$date = mysql_result($result,$i,"regDate");
			echo "<tr>";
			echo "<td><center><a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></center></td>";
			echo "<td>";
			echo "<center><form action=\"includes/process.php\" method=\"POST\">";
			echo "<select name=\"level\" style=\"background-color: #bcc6e1;\">";
			for($x=0;$x<10;$x++)
			{
				echo "<option value=\"$x\" ";
				if($x==$userlevel)
				{
					echo "selected=\"selected\" ";
				}
				echo ">$x</option>";
			}
			echo "</select>";
			echo "<input type=\"hidden\" name=\"subEditUserlevel\" value=\"$user\" />";
			echo "<input type=\"submit\" value=\"Promote\" />";
			echo "</form></center>";
			echo "</td>";
			echo "<td><center>".date("M. j, Y",$time)."</center></td>";
			echo "<td><center>$country</center></td>";
			echo "<td><center>".date("M. j, Y",$date)."</center></td>";
			echo "<td><center><a href=\"#\" onClick=\"if(disp_confirm_delete_user()){buttonClick('includes/process.php?deleteUser=$user');}\" class=\"button\" title=\"Delete User\">Delete</a></center></td>";
			echo "</tr>";
		}
		echo "</table>";
		echo "<br /><center>";
		for($x=0;$x<$num_rows;$x=$x+$maxUsers)
		{
			if($start!=$x)
				echo "<a href=\"adminUsers.php?start=$x\">".(($x/$maxUsers)+1)."</a>&nbsp;&nbsp;&nbsp;";
			else
				echo (($x/$maxUsers)+1)."&nbsp;&nbsp;&nbsp;";
		}
		echo "</center>";
	}
}
function displayGenderStats()
{
	global $database;
	$males = $database->query("SELECT gender FROM ".TBL_USERS." WHERE gender='Male'");
	$females = $database->query("SELECT gender FROM ".TBL_USERS." WHERE gender='Female'");
	$num_males = mysql_num_rows($males);
	$num_females = mysql_num_rows($females);
	$total = $num_males + $num_females;
	echo "<table cellpadding=\"0\" cellspacing=\"0\">";
	echo "<tr><td width=\"50%\" align=\"right\" class=\"stats\">Male:</td><td width=\"25%\" class=\"stats\"><center>$num_males</center></td><td width=\"25%\" align=\"right\" class=\"stats\">".number_format(((100/$total)*$num_males),2)."%</td></tr>";
	echo "<tr><td align=\"right\" class=\"stats\">Female:</td><td class=\"stats\"><center>$num_females</center></td><td align=\"right\" class=\"stats\">".number_format(((100/$total)*$num_females),2)."%</td></tr>";
	echo "</table>";
}
function displayCountryStats()
{
	global $database;
	$retval = $database->query("SELECT * FROM ".TBL_COUNTRIES." WHERE count!='0' ORDER BY country ASC");
	$num_rows = mysql_num_rows($retval);
	$total = $database->getNumMembers();
	echo "<table cellpadding=\"0\" cellspacing=\"0\">";
	for($i=0;$i<$num_rows;$i++)
	{
		$country = mysql_result($retval,$i,"country");
		$code = mysql_result($retval,$i,"code");
		$count = mysql_result($retval,$i,"count");
		echo "<tr>";
		echo "<td align=\"right\" class=\"stats\"><a href=\"users.php?country=$code\" >$country</a>:</td>";
		echo "<td class=\"stats\"><center>$count</center></td>";
		echo "<td align=\"right\" class=\"stats\">".number_format(((100/$total)*$count),2)."%</td>";
		echo "<tr>";
	}
	echo "</table>";
}
function displayNews($maxNews)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_NEWS." ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);

	$start = 0;
	if(isset($_GET['start']))
	{
		$start = $_GET['start'];
	}
	for($i=$start;$i<$num_rows && $i<$start+$maxNews;$i++)
	{
		$id = mysql_result($result,$i,"id");
		$title = mysql_result($result,$i,"title");
		$content = mysql_result($result,$i,"content");
		$time = mysql_result($result,$i,"timestamp");
		$user = mysql_result($result,$i,"author");
		echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><font size=\"+1\"><b>$title</b></font></td></tr>";
		echo "<tr><td><font color=\"#2f3c62\"><b>".date("F j, Y - g:i A",$time)." - by <a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></b></font><br /><br /></td></tr>";
		echo "<tr><td>$content<br /><br /></td></tr>";
		echo "<tr><td align=\"right\"><span class=\"button\" onMouseOver=\"linkOver(this);\" onMouseOut=\"linkOut(this);\" onClick=\"changeActive('comment$id');\">View Comments (".$database->getCommentCount($id).")</span> / <span class=\"button\" onMouseOver=\"linkOver(this);\" onMouseOut=\"linkOut(this);\" onClick=\"changeActive('$id');\">Add Comment</span><br />";
		displayAddComment($id);
		echo "</td></tr>";
		echo "<tr><td align=\"right\">";
		displayComments($id);
		echo "</td></tr>";
		echo "</table><br />";
	}
	echo "<br /><center>";
	for($x=0;$x<$num_rows;$x=$x+$maxNews)
	{
		if($start!=$x)
			echo "<a href=\"index.php?start=$x\">".(($x/$maxNews)+1)."</a>&nbsp;&nbsp;&nbsp;";
		else
			echo (($x/$maxNews)+1)."&nbsp;&nbsp;&nbsp;";
	}
	echo "</center>";
}
function displayNewsAdmin($maxNews)
{
	global $database;
	$result = $database->query("SELECT * FROM ".TBL_NEWS." ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);

	$start = 0;
	if(isset($_GET['start']))
	{
		$start = $_GET['start'];
	}
	for($i=$start;$i<$num_rows && $i<$start+$maxNews;$i++)
	{
		$id = mysql_result($result,$i,"id");
		$title = mysql_result($result,$i,"title");
		$content = mysql_result($result,$i,"content");
		$time = mysql_result($result,$i,"timestamp");
		$user = mysql_result($result,$i,"author");
		echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr><td><font size=\"+1\"><b>$title</b></font></td></tr>";
		echo "<tr><td><font color=\"#2f3c62\"><b>".date("F j, Y - g:i A",$time)." - by <a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></b></font><br /><br /></td></tr>";
		echo "<tr><td>$content<br /><br /></td></tr>";
		echo "<tr><td align=\"right\"><a href=\"adminNews.php?edit=$id\">Edit</a><br /></td></tr>";
		echo "</table>";
	}
	echo "<br /><center>";
	for($x=0;$x<$num_rows;$x=$x+$maxNews)
	{
		if($start!=$x)
			echo "<a href=\"adminNews.php?start=$x\">".(($x/$maxNews)+1)."</a>&nbsp;&nbsp;&nbsp;";
		else
			echo (($x/$maxNews)+1)."&nbsp;&nbsp;&nbsp;";
	}
	echo "</center>";
}
function displayComments($attachid)
{
	global $database,$session;
	$result = $database->query("SELECT * FROM ".TBL_COMMENTS." WHERE attachid='$attachid' ORDER BY timestamp DESC");
	$num_rows = mysql_num_rows($result);

	echo "<table id=\"comment$attachid\" cellpadding=\"0\" cellspacing=\"0\" class=\"hideable\">";
	echo "<tr><td>";
	echo "<table class=\"blueBox\" width=\"70%\">";
	for($i=0;$i<$num_rows;$i++)
	{
		$user = mysql_result($result,$i,"creator");
		$comment = mysql_result($result,$i,"comment");
		$time = mysql_result($result,$i,"timestamp");
		echo "<tr><td align=\"left\">$comment</td></tr>";
		echo "<tr><td align=\"right\">".date("M. j, Y",$time)." - by <a href=\"profile.php?user=$user\" title=\"View Profile\">$user</a></td></tr>";
		if($session->userlevel>1)
		{
			$id = mysql_result($result,$i,"id");
			echo "<tr><td align=\"right\">";
			echo "<a href=\"includes/process.php?deleteComment=$id\" title=\"Delete Comment\">Delete</a>";
			echo "</td></tr>";
		}
		echo "<tr><td><center><hr width=\"90%\" size=\"1\"></center></td></tr>";
	}
	echo "</table>";
	echo "</td></tr>";
	echo "</table>";
}
function displayAddComment($attachid)
{
	global $session;
	if(!$session->logged_in)
	{
		echo "<table id=\"$attachid\" cellspacing=\"0\" cellpadding=\"3\" class=\"hideable\">";
		echo "<tr><td>";
		echo "You Must Be Logged In to Post Comments";
		echo "</td></tr>";
		echo "</table>";
	}
	else
	{
		echo "<form action=\"includes/process.php\" method=\"POST\">";
		echo "<table id=\"$attachid\" cellspacing=\"0\" cellpadding=\"3\" class=\"hideable\">";
		echo "<tr>";
		echo "<td><textarea name=\"comment\" rows=\"4\" cols=\"45\" style=\"background-color: #bcc6e1;\"></textarea></td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td align=\"right\">";
		echo "<input type=\"hidden\" name=\"subAddComment\" value=\"$attachid\">";
		echo "<input type=\"submit\" value=\"Add Comment\">";
		echo "</td>";
		echo "</tr>";
		echo "</table>";
		echo "</form>";
	}
}
?>